<?php

namespace frontend\models\zyy;

use Yii;

/**
 * This is the model class for table "{{%user}}".
 *
 * @property int $id
 * @property string $username 用户名
 * @property string $password 密码
 * @property string|null $head_ico 头像
 *
 * @property AccountLog[] $accountLogs
 * @property Address[] $addresses
 * @property AssembleActive[] $assembleActives
 * @property Favorite[] $favorites
 * @property FindPassword[] $findPasswords
 * @property GoodsCar[] $goodsCars
 * @property Invoice[] $invoices
 * @property Member $member
 * @property NotifyRegistry[] $notifyRegistries
 * @property OauthUser[] $oauthUsers
 * @property OnlineRecharge[] $onlineRecharges
 * @property PointLog[] $pointLogs
 * @property Withdraw[] $withdraws
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['username', 'password'], 'required'],
            [['username'], 'string', 'max' => 20],
            [['password'], 'string', 'max' => 32],
            [['head_ico'], 'string', 'max' => 255],
            [['username'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'username' => 'Username',
            'password' => 'Password',
            'head_ico' => 'Head Ico',
        ];
    }

    /**
     * Gets query for [[AccountLogs]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getAccountLogs()
    {
        return $this->hasMany(AccountLog::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[Addresses]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getAddresses()
    {
        return $this->hasMany(Address::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[AssembleActives]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getAssembleActives()
    {
        return $this->hasMany(AssembleActive::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[Favorites]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getFavorites()
    {
        return $this->hasMany(Favorite::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[FindPasswords]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getFindPasswords()
    {
        return $this->hasMany(FindPassword::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[GoodsCars]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getGoodsCars()
    {
        return $this->hasMany(GoodsCar::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[Invoices]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getInvoices()
    {
        return $this->hasMany(Invoice::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[Member]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getMember()
    {
        return $this->hasOne(Member::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[NotifyRegistries]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getNotifyRegistries()
    {
        return $this->hasMany(NotifyRegistry::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[OauthUsers]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getOauthUsers()
    {
        return $this->hasMany(OauthUser::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[OnlineRecharges]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getOnlineRecharges()
    {
        return $this->hasMany(OnlineRecharge::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[PointLogs]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getPointLogs()
    {
        return $this->hasMany(PointLog::class, ['user_id' => 'id']);
    }

    /**
     * Gets query for [[Withdraws]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getWithdraws()
    {
        return $this->hasMany(Withdraw::class, ['user_id' => 'id']);
    }
}
